import request from '@/utils/request';
import { getParamsSuffix } from '@/utils/paramsUtils';

/**
 * 分页
 * @param query
 * @returns {Promise<any>}
 */
export async function listAllData(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/orgsetting/listAllData?${params}`);
}

/**
 * 获取所有省份数据
 * @param query
 * @returns {Promise<any>}
 */
export async function getAllProvince() {
  return request(`/api/cdcerservice/v1/orgsetting/getAllProvince`);
}

/**
 * 查询市区街道级联
 * @returns {Promise<any>}
 * @param query
 */
export async function getAllProvinceCity(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/orgsetting/getAllProvinceCity?${params}`);
}

/**
 * 获取城市下的区街道信息
 * @returns {Promise<any>}
 * @param query
 */
export async function getDistrictAndStreet(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/orgsetting/getDistrictAndStreet?${params}`);
}

/**
 * 导出所有机构数据
 * @returns {Promise<any>}
 * @param params
 */
export async function exportOrgData(params) {
  return request(`/api/cdcerservice/v1/orgsetting/exportOrgData`, {
    method: 'POST',
    requestType: 'form',
    responseType: 'blob',
    data: {
      ...params
    }
  });
}
